<div id="starrating" class="hreview-aggregate">
	<p>{%Product rating%}: <span class="rating" id="rating-<?php echo $this->productId;?>">
			<span class="average"><?php echo $this->rating;?></span>/<span class="best">5</span>
			</span>(<span class="count" id="starrating_totalvotes"><?php echo $this->totalVotes; ?></span> {%votes%})
	</p>
	<div id="starratingbar">{%Loading%}...</div>
	<span class="item">{%Click stars to rate%} <a href="<?php echo $this->siteUrl.$this->productPage.'.html'; ?>" class="fn url" title="<?php echo $this->productName;?>"><?php echo $this->productName;?></a></span>
</div>
<script type="text/javascript" src="<?php echo $this->siteUrl; ?>system/js/jquery/plugins/raty/jquery.raty.min.js">
</script>
<script type="text/javascript">
    $('#starratingbar').html('').raty({
            path: 'system/js/jquery/plugins/raty/img/'
        , hintList: ["{%Very poor%}","{%Not that bad%}","{%Average%}","{%Good%}","{%Perfect%}"]
        , scoreName: 'rating'
        , showHalf: true
        , start: <?php echo $this->rating; ?>
        , onClick: function(rating){
            $.ajax({
                url:'<?php echo $this->siteUrl; ?>sys/backend_shopping/rateproduct/'
                , type: 'POST'
                , dataType: 'json'
                , data: {
                    productId: '<?php echo $this->productId; ?>',
                    rating: rating
                }
                , success: function(responce){
                    if (true===responce.done) {
                        $.fn.raty.readOnly(true);
                        $.fn.raty.start(responce.rating);
                        $('#rating-<?php echo $this->productId;?>.rating').text(responce.rating);
                        $('#starrating_totalvotes').text(responce.totalvotes);
                    } else if ('cancel'==responce.done) {
                        $.fn.raty.readOnly(true);
                        $.fn.raty.start(<?php echo $this->rating; ?>);
                        var tmp = $('#starrating_totalvotes').html()
                        $('#starrating').append('<p>{%Sorry, You have already voted%}</p>');
                    } else if (false===responce.done) {
                        $('#starrating_totalvotes').html('<b>{%Vote fail%}!</b>')
                    }
                }
            })
        }
    })
</script>